<template>
	<div class="task-node" :style="nodeModel"  @mouseup="changeNodePos" ref="node">
		<i class="el-icon-edit editpanel-visible-icon" @click="onEditIconClickHandler"></i>
		<div class="task-node-title">
			<i class="el-icon-user-solid flow-node-drag"></i>
			<span style="display: inline-block;margin-top: 1px;margin-left: 5px;">任务节点</span>
		</div>
		<div class="task-node-content">
			{{nodeModel.name}}
		</div>
		<el-drawer :title="'任务节点'+nodeModel.id" v-model="drawerVisible" :append-to-body="true">
			<el-form ref="form" label-width="100px">
				<el-form-item label="名称">
					<el-input v-model="currentNodeModel.name" size="small"></el-input>
				</el-form-item>
				<el-divider content-position="left">节点事件</el-divider>
				<el-form-item label="start事件">
					<el-input v-model="currentNodeModel.startEventExpression" size="small" type="textarea"></el-input>
				</el-form-item>
				<el-form-item label="end事件">
					<el-input v-model="currentNodeModel.endEventExpression" size="small" type="textarea"></el-input>
				</el-form-item>
			</el-form>
			<el-tabs>
				<el-tab-pane label="分配">
					<div style="margin-left: 10px;">
						<div>
							<label>按用户分配</label>
							<el-input v-model="currentNodeModel.userAssignment" size="small" style="width:85%;">
							</el-input>
							<i class="el-icon-search"></i>
						</div>
						<div style="margin-top: 10px;">
							<label>按角色分配</label>
							<el-input v-model="currentNodeModel.roleAssignment" size="small" style="width:85%;">
							</el-input>
							<i class="el-icon-search"></i>
						</div>
						<div>
							<label>分配表达式</label>
							<el-input v-model="currentNodeModel.assignmentExpression" size="small"></el-input>
						</div>
					</div>
				</el-tab-pane>
				<el-tab-pane label="任务" style="margin-left: 10px;">
					<div>
						<el-checkbox v-model="currentNodeModel.sequence" v-show="false">顺序执行</el-checkbox>
					</div>
					<div style="border-bottom: 1px solid #E6E6E6;margin-top:5px;">
						<span style="font-size:18px;color:#7C7BAD;">完成规则</span>
					</div>
					<div>
						<el-radio v-model="currentNodeModel.completeRule" label="all">全部完成</el-radio>
					</div>
					<div style="margin-top: 10px;">
						<el-radio v-model="currentNodeModel.completeRule" label="count">完成个数</el-radio>
					</div>
					<div>个数<el-input v-model="currentNodeModel.count" size="mini" style="width: 30%;">
						</el-input>
					</div>
					<div style="margin-top: 10px;">
						<el-radio v-model="currentNodeModel.completeRule" label="percent">完成百分比</el-radio>
					</div>
					<div>百分比<el-input v-model="currentNodeModel.percent" size="mini" style="width: 30%;">
						</el-input>%</div>
				</el-tab-pane>
				<el-tab-pane label="操作" style="margin-left: 10px;">
					<el-row>
						<el-col :span="8">
							<el-switch v-model="currentNodeModel.canUserInput" active-text="用户输入"></el-switch>
						</el-col>
						<el-col :span="8">
							<el-switch v-model="currentNodeModel.canBack" active-text="打回"></el-switch>
						</el-col>
					</el-row>	
				</el-tab-pane>
			</el-tabs>
		</el-drawer>
	</div>
</template>

<script>
	export default {
		name: "TaskNode",
		props: ["nodeModel"],
		data() {
			return {
				drawerVisible: false,
				"currentNodeModel": this.nodeModel,
			}
		},
		beforeMount() {
			if (this.currentNodeModel.completeRule == undefined) {
				this.currentNodeModel.completeRule = "all";
			}
		},
		methods: {
			changeNodePos() {
				this.currentNodeModel["left"] = this.$refs.node.style.left;
				this.currentNodeModel["top"] = this.$refs.node.style.top;
			},onEditIconClickHandler(){
				this.drawerVisible = true;
				this.$store.state.workflowDesigner.setSelectedComponent(this);
			}
		},
	}
</script>

<style>
	
</style>
